# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-rdpy
pkgname=('python2-rdpy' 'python-rdpy')
_pkgname=rdpy
pkgver=1.3.2
_pyver=3.13
pkgrel=21
epoch=1
pkgdesc='Remote Desktop Protocol in Twisted Python.'
arch=('any')
url='https://pypi.org/project/rdpy/#files'
license=('GPL-3.0-or-later')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
        "rle.patch")
sha512sums=('66dcafc975da7ecf2359fe1c2297dd2a219f54d405f47a045067dc34f3e35b18198bf7f23474523875b9623e1b79600a371ca6fd254c5c6886118668e03edd2a'
            '8c13a4d3c44fa4ba79470c9e8f8f3be3a99c298510fa1c27d356b694a9bc5409a74cd064e1be97959d09356d327b7eda4a0c935ddd542ddc88a6c90383e83829')

prepare() {
  patch -d "$_pkgname-$pkgver" -p1 < rle.patch
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-rdpy() {
  depends=('python2' 'python2-pyopenssl' 'python2-rsa' 'python2-twistedx'
           'python2-pyasn1' 'python2-service-identity' 'python2-qt4reactor')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  for i in "$pkgdir/usr/bin/"* ; do
    mv $i "${i}2"
  done
}

package_python-rdpy() {
  depends=('python' 'python-pyopenssl' 'python-rsa' 'python-twisted'
           'python-pyasn1' 'python-service-identity' 'python-qt4reactor')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  rm -f \
    "$pkgdir/usr/lib/python$_pyver/site-packages/rle.cpython-${_pyver//./}-x86_64-linux-gnu.so"
}

